package com.huawei.knowledge.doc;

import com.huawei.knowledge.doc.model.DocClassifyModel;
import com.huawei.knowledge.doc.model.DocumentDetailModel;
import com.huawei.knowledge.doc.model.DocumentModel;
import com.huawei.knowledge.doc.service.DocumentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2018/4/22/022.
 */
@RestController
@RequestMapping("/doc")
public class DocumentController {

    @Autowired
    private DocumentService documentService;

    /**
     * 查询文档分类列表
     *
     * @return 文档分类列表
     */
    @RequestMapping("/docClassifyList")
    public List<DocClassifyModel> queryDocClassifyList() {
        return documentService.queryDocClassify();
    }

    @RequestMapping("/docList")
    public List<DocumentModel> querDocList(@RequestBody Map<String, String> reqMap) {
        return documentService.queryDocList(reqMap.get("classifyIndex"));
    }

    @RequestMapping("/docDetail")
    public DocumentDetailModel showDocumentIndexPage(@RequestBody Map<String, String> reqMap) {
        return documentService.showDocumentIndexPage(reqMap.get("classifyIndex"),
                reqMap.get("docIndex"));
    }

    @RequestMapping("/docPage")
    public String showDocumentByPage(@RequestBody Map<String, String> reqMap) {
        return documentService.showDocumentByPage(reqMap.get("docDir"),
                reqMap.get("docPageFile"));
    }

    @RequestMapping("/updateViewTimes")
    public String updateViewTimes(@RequestBody Map<String, String> reqMap) {
        documentService.upDateViewTimes(reqMap.get("classifyIndex"),
                reqMap.get("docIndex"));
        return "SUCCESS";
    }

}
